<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>添加物流</title>
    <script type="text/javascript">
      Ext.onReady(function(){
        var number = Ext.create('Ext.form.field.Number', {
          fieldLabel: '编号',
          blankText: "编号不能为空",
          name: 'number',
          anchor: '95%'
        });

        var logisticsTypeArrayStore = Ext.create('Ext.data.ArrayStore', {
          //fields: ['value', 'text'],
          fields: ['text'],
          data : logisticsTypeArray
        });

        var logisticsType = Ext.create('Ext.form.ComboBox', {
          fieldLabel: '类型',
          store: logisticsTypeArrayStore,
          valueField:'text',
          displayField:'text',
          allowBlank: false,
          typeAhead: true,
          mode: 'local',
          
          
          name:'sub_type',
          emptyText:'选择物流类型...',
          //allowBlank: false,
          anchor: '90%'
        });
        
        var name = Ext.create('Ext.form.field.Text', {
          fieldLabel: '名称',
          allowBlank: false,
          blankText: "物流名称不能为空",
          name: 'name',
          anchor: '95%'
        });

        var phone = Ext.create('Ext.form.field.Text', {
          fieldLabel: '电话',
          allowBlank: false,
          name: 'phone',
          anchor: '95%'
        });

        var fax = Ext.create('Ext.form.field.Text', {
          fieldLabel: '传真',
          name: 'fax',
          anchor: '95%'
        });

        var linkman = Ext.create('Ext.form.field.Text', {
          fieldLabel: '联系人',
          name: 'linkman',
          anchor: '95%'
        });

        var email = Ext.create('Ext.form.field.Text', {
          fieldLabel: '电子邮箱',
          name: 'email',
          anchor: '95%'
        });

        var bank = Ext.create('Ext.form.field.Text', {
          fieldLabel: '开户银行',
          name: 'bank',
          anchor: '95%'
        });

        var bankAccount = Ext.create('Ext.form.field.Text', {
          fieldLabel: '银行账户',
          name: 'bank_account',
          anchor: '95%'
        });

        var address = Ext.create('Ext.form.field.Text', {
          fieldLabel: '地址',
          allowBlank: false,
          name: 'address',
          anchor: '97%'
        });

        var desc = Ext.create('Ext.form.TextArea', {
          fieldLabel: '描述',
          name: 'description',
          height:80,
          anchor: '97%'
        });
        
        var newLogisticsForm = Ext.create('Ext.form.Panel', {
          fieldDefaults: {
            labelWidth: 55,
            labelAlign: 'right'
          },
          url:'/logistics/create',
          frame:true,
          //title: '添加物流',
          bodyStyle:'padding:5px 5px 0',
          width: 600,
          //height:300,
          items: [{
              layout: 'column',
              xtype: 'container',
              items: [{
                  columnWidth: .25,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [number]
                },{
                  columnWidth: .25,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [logisticsType]
                }, {
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [name]
                }]
            },{
              layout: 'column',
              xtype: 'container',
              items: [{
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [phone]
                },{
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [fax]
                }]
            },{
              layout: 'column',
              xtype: 'container',
              items: [{
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [linkman]
                },{
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [email]
                }]
            },{
              layout: 'column',
              xtype: 'container',
              items: [{
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [bank]
                },{
                  columnWidth: .5,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [bankAccount]
                }]
            },{
              layout: 'column',
              xtype: 'container',
              items: [{
                  columnWidth: 1,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [address]
                }]
            },{
              layout: 'column',
              xtype: 'container',
              items: [{
                  columnWidth: 1,
                  layout: 'anchor',
                  xtype: 'container',
                  items: [desc]
                }]
            },authToken],
          buttons: [{
              text: '提交',
              iconCls: 'icon-save',
              handler: function(){
                // check form value
                if (newLogisticsForm.form.isValid()) {
                  this.disable();
                  newLogisticsForm.form.submit({
                    method: 'POST',
                    success: function(result, response){
                      if (response.result.info == "成功") {
                        //添加成功后，隐藏窗口，并刷新Grid
                        newLogisticsWin.destroy();
                      }
                      else {
                        Ext.MessageBox.alert('消息', response.result.info);
                      }
                    },
                    failure: function(result, response){
                      Ext.MessageBox.alert('提示', result.responseText);
                      newLogisticsWin.destroy();
                    }
                  });
                }
                else {
                  Ext.MessageBox.alert('错误提示', '请按要求填写必输选项.');
                }
              }
            },{
              text: '关闭',
              iconCls: 'exit',
              handler: function(){
                newLogisticsWin.destroy();
              }
            }]
        });
        newLogisticsForm.render('new_logistics_form');
      })
    </script>
  </head>
  <body>
    <div id="new_logistics_form"></div>
  </body>
</html>
